package top.liuzhenyu.springboot3.entity.message;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.liuzhenyu.springboot3.entity.auth.TbUser;
import top.liuzhenyu.springboot3.validate.CommonValidate;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

@Data
@TableName("tb_message")
public class TbMessage implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    // 自增主键
    @TableId(type = IdType.AUTO)
    private Integer id;
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Integer uid;
    @NotBlank(message = "标题不能为空", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    @Length(min = 5, message = "标题长度不能小于5", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    private String title;
    @NotBlank(message = "内容不能为空", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    @Length(min = 10, message = "内容长度不能小于10", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    private String content;
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Integer hits;
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Integer replyCount;
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Integer likes;
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Date created;

    @TableField(exist = false)
    private TbUser user;
    @TableField(exist = false)
    private boolean mine;
}
